This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Cloneable interface { | |
Clone() Cloneable; | |
} | |
type MapA map[int]string; | |
type MapB map[string]int; | |
func (m MapA) Clone() Clonable { | |
nmap := make(MapA); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
import "reflect" | |
type Cloneable interface { | |
Clone() Cloneable; | |
} | |
type Mapable interface { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
import "reflect" | |
type Cloneable interface { | |
Clone() Cloneable; | |
} | |
type MapA map[int]string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case ServerRequest(key) => | |
reply(sessionMap.get(key) match { | |
case Some(svr) => | |
SessionSuccess(svr) | |
case None => | |
SessionFailure("No session found for supplied key") | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait NeoIterable[T] extends Iterator[T] { | |
def first() : T = { | |
this.take(1).toList.head | |
} | |
} | |
implicit def jiterable2iterable[T](it: java.lang.Iterable[T]) = new Wrapper[T](it.iterator()) with NeoIterable[T] | |
use: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type bsonvalue = | |
| BDouble of float | |
| BString of string | |
| BObject of bsondoc | |
| BArray of list bsonvalue | |
| BBinary of int * string | |
| BUndefined | |
| BOid of string | |
| BBool of bool | |
| BDate of int64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getNextMsgID :: Peer -> IO Int64 | |
getNextMsgID peer = modifyMvar (pCurrent peer) (\x -> do { let y = x + 1; return (y, y); } ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
forMpar :: [a] -> (a -> IO b) -> IO [b] | |
forMpar xs fun = do | |
sem <- newQSem (length xs) | |
c <- newChan | |
forM_ xs (\x -> forkIO $ wrap fun x c sem) | |
waitQSem sem | |
collect (length xs) c [] | |
where wrap f item chan qsem = f item >>= writeChan chan >> signalQSem qsem | |
collect 0 chan acc = return acc | |
collect count chan acc = do !i <- readChan chan; collect (count - 1) chan i::acc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syncRequests :: BsonDoc -> [Peer] -> IO [BsonDoc] | |
syncRequests doc prs = do | |
sem <- newQSem (length prs) | |
c <- newChan | |
forM_ prs $ \p -> do | |
(mid, msg) <- initMessage p MsgTypeCall 0 doc | |
registerSync p c sem mid | |
putMessage (pConn p) msg | |
waitQSem sem | |
collect (length prs) c [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html class="no-js " lang="en-US"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script type="text/javascript">Olelo = {"path":"","page_name":"","page_new":true,"page_modified":false,"page_path":"","page_title":"Root","page_version":"","page_next_version":"","page_previous_version":"","page_mime":"text/x-creole","default_mime":"text/x-creole","user_logged_in":true,"user_name":"10.16.64.79"};</script><title>My Project - New Page</title><link href="/static/images/favicon.png?1" rel="shortcut icon" type="image/png"><base href="http://172.17.3.122:8080/"><link rel="stylesheet" href="/static/themes/atlantis/style.css?1289221523" type="text/css" title="atlantis"><script src="/static/script.js?1289221523" type="text/javascript" async="async"></script><link rel="stylesheet" href="/_/assets/assets.css?1289221523" type="text/css"><link rel="alternate" type="application/atom+xml" title="Sitewide Atom Changelog" href="/?format=atom&output=changelog"><link rel="alternate" ty |
OlderNewer